<template>
  <!-- 登入界面 -->
  <div class="box" v-show="loginshow" @mousewheel.prevent="">
    <div class="loginbox" @click="closelogin">
      <div class="login" @click.stop="" v-show="loginbox">
        <p class="textp" @click="numberlogin">手机号登录</p>
        <p class="textp" @click="Qrcodelogin">二维码登录</p>
      </div>
      <numberlogin></numberlogin>
      <Qrcodelogin></Qrcodelogin>
    </div>
  </div>
</template>

<script>
import numberlogin from '../components/login/NumberLogin'
import Qrcodelogin from '../components/login/QrcodeLogin'
export default {
  setup () {},
  components: {
    numberlogin,
    Qrcodelogin
  },
  data () {
    return {
      loginshow: false,
      loginbox: true
    }
  },
  methods: {
    closelogin () {
      this.loginshow = false
    },
    numberlogin () {
      this.loginbox = false
      this.$bus.$emit('numberlogin')
    },
    Qrcodelogin () {
      this.loginbox = false
      this.$bus.$emit('Qrcodelogin')
    }
  },
  mounted () {
    // 点击登录按钮显示登录框
    this.$bus.$on('loginshow', (res) => {
      this.loginshow = true
      this.loginbox = true
    })
    // 点击关闭窗口
    this.$bus.$on('loginclose', (res) => {
      this.loginshow = false
    })
    // 登录成功隐藏登录框
    this.$bus.$on('LoginSuccess', (res) => {
      this.loginshow = false
    })
  }
}
</script>

<style scoped>
.box {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 3;
}
.loginbox {
  width: 100%;
  height: 100%;
  position: relative;
}
.login {
  width: 400px;
  height: 400px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid #d8d8d8;
  background-color: rgb(255, 255, 255);
}
.textp {
  width: 90px;
  line-height: 30px;
  color: white;
  font-weight: bold;
  text-align: center;
  background-color: #2d2d2d;
  cursor: pointer;

}
.numberlogin{
  width: 400px;
  height: 300px;
  background-color: black;
  position: relative;
}
</style>
